package com.walnut.lom_system.controller;

import com.walnut.lom_system.common.annotation.DoLog;
import com.walnut.lom_system.common.lang.OperateTypeContains;
import com.walnut.lom_system.common.lang.ResultInfo;
import com.walnut.lom_system.domain.entity.UserLoginInfo;
import com.walnut.lom_system.service.UserLoginInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.security.Principal;

/**
 * @author chenhetao
 * @version 1.0
 * @className MenuController
 * @description TODO
 * @date 2022/4/4 23:38
 */
@Controller
@Api(tags = "认证相关接口")
@RequestMapping("/auth")
public class MenuController {

    @Autowired
    private UserLoginInfoService userLoginInfoService;



    @ApiOperation("本人菜单获取接口")
//    @GetMapping("/menu")
    @DoLog(operateModule = "Menu", operateType = OperateTypeContains.OPERATE_SELECT, operateDesc = "获取用户对应的菜单列表")
    public ResultInfo<Object> getOwnMenu(){
        UserDetails userDetails = (UserDetails) SecurityContextHolder.getContext().getAuthentication() .getPrincipal();
        System.out.println(userDetails);
//        System.out.println(principal.getName());
//        UserLoginInfo userLoginInfo = userLoginInfoService.queryUserByUsername(principal.getName());
//
//        获取权限信息
//        String userAuthorityInfo = userLoginInfoService.getUserAuthorityInfo(userLoginInfo.getId());
//        String[] authorityArray = StringUtils.tokenizeToStringArray(userAuthorityInfo, ",");
        return null;
    }
}
